<template>
    <!-- 图片列表 -->
    <div>
        <!-- 顶部滑动区域 -->
        <div id="slider" class="mui-slider">
            <div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
                <div class="mui-scroll" style="transform: translate3d(-47px, 0px, 0px) translateZ(0px); transition-duration: 0ms; transition-timing-function: cubic-bezier(0.165, 0.84, 0.44, 1);">
                    <a :class="['mui-control-item', item.id ==0?'mui-active':'']" href="#item1mobile" data-wid="tab-top-subpage-1.html" v-for="item in imagesCategory" :key='item.id' @click="getImageList(item.id)">
                        {{ item.title }}
                    </a>
                </div>
            </div>
        </div>
        <!-- 图片列表区域 -->
        <ul class="photo-list">
            <router-link v-for="item in list" :key='item.id' :to="'/home/photoinfo/'+item.id" tag="li">
                <img v-lazy="item.img_url" >
                <div class="info">
                    <h1 class="info-title">{{ item.title }}</h1>
                    <p class="info-body" v-html="item.zhaiyao"></p>
                </div>
            </router-link>
        </ul>
    </div>
</template>
<script>
import {Toast} from 'mint-ui';
import mui from "../../lib/mui/js/mui.min.js"
export default {
    data(){
        return {
            list:[],//图片集合
            imagesCategory:[]//获取轮动头部分类
        }
    },
    mounted(){
        mui('.mui-scroll-wrapper').scroll({
            deceleration: 0.0005, //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006e
        });
    },
    created(){
        this.getImageCategory();
        this.getImageList(0);
    },
    methods:{
        getImageCategory(){//获取图片标题集合
            this.$http.get('getimagecategory').then(result=>{
                console.log(result.body);
                if(result.body.status === 0){
                    //手动添加一个全部
                    result.body.data.unshift({title:'全部',id:0});
                    this.imagesCategory = result.body.data;
                }else{
                    Toast('获取分类失败');
                }
            })
        },
        getImageList(cateId){//获取所有的图片
            this.$http.get('getimages/'+cateId).then(result=>{
                console.log(result.body);
                if(result.body.status === 0){
                    this.list = result.body.data;
                }
            })
        }
    }
}
</script>
<style lang="scss" scoped>
 * { touch-action: pan-y; } 
.photo-list{
    list-style: none;
    padding: 10px;
    margin: 0;
    li{
        background-color: #ccc;
        text-align: center;
        box-shadow: 0 0 9px #999;
        position: relative;
        margin-bottom: 10px;
        img{
            width: 100%;
            height: 100%;
            vertical-align: middle;
        }
        image[lazy=loading] {
            width: 40px;
            height: 300px;
            margin: auto;
        }
        .info{
            width: 100%;
            color: #fff;
            text-align: left;
            position: absolute;
            bottom: 0;
            background-color:rgba(0,0,0,0.4);
            max-height: 84px;
            .info-title{
                font-size: 14px;
            }
            .info-body{
                max-height: 60px;
                font-size: 13px;
                overflow: hidden;
            }
        }
    }
}
</style>

